package com.wyf.video.adapter

import android.content.Context
import android.text.Layout
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.wyf.video.R
import com.wyf.video.model.Bt
import org.jetbrains.anko.find

/**
 * Created by Administrator on 2017/11/21.
 */
class SearchResultAdapter(context: Context,list2: List<Bt>):BaseAdapter() {
    var context:Context?=null
    var list:List<Bt>
    init {
        this.context = context
        this.list = list2
    }


    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var root  = LayoutInflater.from(context).inflate(R.layout.item_list_horiztoal,null)
        var poster = root.findViewById<ImageView>(R.id.film_img_poster)
        Glide.with(context).load(list.get(position).poster).into(poster)
        root.find<TextView>(R.id.film_text_name).text = list[position].name
        var str = ""
        for (i in list[position].actor){
            str+=i.trim()+" "
        }
        root.find<TextView>(R.id.film_text_actor).text = str

        return root
    }

    override fun getItem(position: Int): Any {
        return position

    }

    override fun getItemId(position: Int): Long {
        return position.toLong()

    }

    override fun getCount(): Int {
        return list.count()
    }
}